﻿package at.geoathome.utils
{	
	/**
	 * ...
	 * @author Thomas Klana
	 */
	public class DevUtils
	{
		public static const LOG_OFF : uint 	= 0;
		public static const LOG_TRACE :uint = 1;
		public static const LOG_SOS : uint	= 2;
		
		private static var _instance:DevUtils = null;
		
		/* Valid Modes [0-2]
		 * 0: Off
		 * 1: Trace
		 * 2: SOS-Logger
		 * * * * * * * * * * * * * */
		private var _debug_mode:uint = 0;
		
		public function DevUtils(singleton_enforcer:SingletonEnforcer)
		{
			
		}	
		
		public static function getInstance():DevUtils
		{
			if (_instance == null)
				_instance = new DevUtils(new SingletonEnforcer());
			return _instance;
		}
		
		public static function get debug_mode():uint
		{
			return getInstance()._debug_mode;
		}
		
		public static function set debug_mode(value:uint):void
		{
			if (DevUtils.LOG_OFF <= value && value <= DevUtils.LOG_SOS && getInstance()._debug_mode != value) 
			{
				close();
				getInstance()._debug_mode = value;
				open();
			}
		}
		
		public static function log(object:Object, ...args):void
		{
			switch(getInstance()._debug_mode) 
			{
				case DevUtils.LOG_TRACE:
					trace(object.toString(), args);
					break;
				case DevUtils.LOG_SOS:
					//SOSLogger.trace(object, args);
					break;
			}
		}
		
		public static function open():void
		{
			/*
			if (getInstance()._debug_mode == DevUtils.LOG_SOS)
				SOSLogger.open();
			*/
		}
		
		public static function close():void
		{
			/*
			if (getInstance()._debug_mode == DevUtils.LOG_SOS)
				SOSLogger.close();
			*/
		}
		
	}
}

// SingletonEnforcer
class SingletonEnforcer {}